<template>
  <div class="buildinging _construct">
    <div class="where">
      <router-link to="/index">首页</router-link>
      <span>&gt;</span>
      <a href="#">常见问题</a>
    </div>
    <div class="faq">
      <el-menu :default-active="defaultId" class="el-menu-vertical-demo" v-loading="menuDoading"
        element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0.8)"
        :default-openeds="open_list" @open="handleOpen" @close="handleClose" @select="handleSelect">
        <el-submenu v-for="(item, index) in issueClassify" :index="item.node.node_code">
          <template slot="title">
            <span>{{item.node.node_name}}</span>
          </template>
          <el-menu-item-group>
            <template slot="title"></template>
            <el-menu-item :index="y.id.toString()" v-for="(y, j) in item.contents" :key="j">{{y.title}}
            </el-menu-item>
          </el-menu-item-group>
        </el-submenu>
      </el-menu>
      <div class="fx1">
        <div class="faq-main">
          <div class="faq-detail">
            <h1 >{{messageData.title}}</h1>
            <p class="_content" v-html="messageData.chr_content"></p>
          </div>
          <div class="faq-related">
            <div class="tit">相关问题</div>
            <div class="link">
              <a href="#">政府对企业节能监察</a>
              <a href="#">政府对企业节能监察</a>
              <a href="#">政府对企业节能监察</a>
            </div>
          </div>
          <div class="faq-other">
            <div class="tit">仍需要其它帮助？</div>
            <div class="item">
              <span class="_itemSpan">电话：0755-82873211</span>
              <a href="#" class="_itemA">互助交流平台</a>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="page clear" v-if="pagetotal">
      <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
        layout="prev, pager, next, jumper" :total="pagetotal" prev-text="上一页" next-text="下一页">
        <el-pagination layout="prev, pager, next" :total="1000">
        </el-pagination>
      </el-pagination>
      <a href="#" class="go">确定</a>
    </div>
  </div>
  </div>
</template>
<script>
  import {
    getNodesAllchildrennodes,
    getContentList,
    getCjwtData,
    getContentDetail
  } from '../../api/public'
  export default {
    data() {
      return {
        issueClassify: [],
        issueParameter: {
          lang: "sc",
          node_code: "cjwt",
          show_menu: "-1",
          show_path: "-1",
          is_show: "-1"
        },
        isActive: 0,
        activeNames: ['0'],
        issueCode: {
          ipage: "1",
          page_size: "10",
          condition: {
            node_code: "",
            lang: "sc"
          }
        },
        issueData: [],
        loading: true,
        show: true,
        pagetotal: 0,
        activeName: null,
        open_list: [],
        defaultId: "1",
        menuDoading: true,
        messageSingle: {
          id: "",
          lang: "sc"
        },
        messageData: {}
      }
    },
    methods: {
      //获取栏目的直接下级栏目
      getClassify() {
        getCjwtData({}).then(res => {
          this.menuDoading = false;
          this.issueClassify = res.data;
          //this.open_list.push(this.issueClassify[0].node.node_code+"_"+this.issueClassify[0].contents[0].id);
          this.open_list = [];

          if (this.$route.query.id) {
            this.open_list = [];
            this.open_list.push(this.$route.query.node_code);
            this.open_list.push(parseInt(this.$route.query.id));
            this.defaultId = this.$route.query.id;
          } else {
            this.open_list.push(this.issueClassify[0].node.node_code)
            this.open_list.push(this.issueClassify[0].contents[0].id);
            this.defaultId = this.issueClassify[0].contents[0].id.toString();
          }
          this.messageSingle.id = this.defaultId;
          this.getMessageSingle();


        })
      },
      //查询单个
      getMessageSingle() {
        getContentDetail(this.messageSingle).then(res => {
          this.messageData = res.data;
        })
      },
      //分类on绑定
      issueOn(index, item) {
        this.isActive = index;
        this.issueCode.condition.node_code = item.node_code;
        this.issueCode.ipage = 1;
        this.issueCode.page_size = 10;
        this.activeName = null;
        this.$route.query.id = 0;
        this.getContenData();
      },
      handleChange(val) {
        // console.log(val);
      },
      //获取栏目内容列表
      getContenData() {
        getContentList(this.issueCode).then(res => {
          this.loading = false;
          this.issueData = res.data.list;
          this.pagetotal = res.data.total;
          let id = this.$route.query.id;
          if (res.data.list.length === 0) {
            this.show = false;
          } else {
            for (let index = 0; index < this.issueData.length; index++) {
              if (id) {
                this.issueData[index].id == id - 0;
                this.activeName = index;
              }
            }
            this.show = true;
            this.$nextTick(() => {
              document.getElementsByClassName("el-pagination__jump")[0].childNodes[0].nodeValue = "到第";
            })
          }
        })
      },
      handleSizeChange(val) {
        this.issueCode.ipage = 1;
        this.issueCode.page_size = val;
        this.getContenData();
      },
      handleCurrentChange(val) {
        this.issueCode.ipage = val;
        this.getContenData();
      },
      handleOpen(key, keyPath) {
        console.log("key, keyPath", key, keyPath);
      },
      handleClose(key, keyPath) {
        console.log(key, keyPath);
      },
      handleSelect(key, keyPath) {
        console.log("key, keyPath--", key, keyPath);
        //var params_data=key.split('_');
        this.messageSingle.id = key; //params_data[-1];
        this.getMessageSingle();
      },

    },
    mounted() {

      this.activeName = null;
      this.getClassify();

    },
  }

</script>

<style lang="less">
  .buildinging {
    text-align: center;
    height: calc(100vh - 312px);
  }

  .buildinging h2 {
    color: #fff;
    font-size: 24px;
    margin-bottom: 20px;
  }

  ._construct {
    .el-submenu__title:hover {
      background-color: #0d74b3;
    }

    .el-menu-item-group>ul {
      // padding-left: 24px;
    }


    .faq-other .item {
      overflow: hidden;
    }

    .faq-other ._itemSpan,
    ._itemA {
      float: left;
      display: block;
      background: #ecf7ff;
      font-size: 14px;
      padding: 0 20px;
      line-height: 40px;
      margin-right: 10px;
      color: #000;

    }

    .faq-related .link a:hover,
    .faq-other .item a:hover {
      font-weight: bold;
    }

    .l-collapse-item__header>.is-active {
      background: #0d74b3 !important;
    }


    .el-menu-item-group {
      .is-active {
        background: #5c92fd !important;
        border-left: 3px solid #ffa940;
      }
    }

    .el-collapse-item__wrap {
      border-bottom: 0px;
    }

    .el-menu-item-group__title {
      width: 170px;
      padding: 0px;
    }

    .el-menu {
      border-right: 0px;
      background: #233c8b;
    }

    .el-menu-item:hover {
      background: #5c92fd;
    }

    .el-menu-item {
      min-width: 170px !important;
      color: #fff;
      padding-left: 24px !important;
      padding-right: 0px !important;
    }

    .faq {
      color: #fff;
      min-height: 600px;
      display: flex;
      margin-bottom: 20px;
    }

    .el-menu-vertical-demo {
      margin-right: 22px;
      background: #3153b2;
      width: 200px;
      text-align: left;

      ul {
        width: 200px;
      }

      li {
        font-size: 12px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }

      .el-submenu__title {
        color: #fff;
        background: #3153b2;
        padding-left: 14px !important;
        text-align: left;
      }

      .el-submenu__title i {
        color: #fff;
        font-size: 16px;
        font-weight: bold;
      }
    }

    .faq-tab {
      justify-content: space-between;
      padding: 22px 0;
    }

    .faq-tab a {
      display: block;
      width: 173px;
      height: 34px;
      border: 1px solid #1a86b5;
      line-height: 32px;
      color: #fff;
      text-align: center;
      font-size: 14px;
    }

    .faq-tab li.on a {
      background: #1a86b5;
    }

    .el-collapse-item__header {
      background: #06619a;
      color: #fff;
      border-bottom: 1px solid #1a86b5;
      padding-left: 16px;
      padding-right: 8px;
    }

    .el-collapse {
      border-top: 0px;
      border-bottom: 0px !important;
    }

    .el-collapse-item__content {
      background: #06619a;
      color: #fff;
    }

    .el-icon-arrow-right {
      font-size: 22px;
    }

  }

  .el-loading-parent--relative {
    min-height: 490px;
  }

  .el-collapse {
    width: 100%;
  }


  .el-pagination.is-background .el-pager li:not(.disabled).active {
    background-color: #0b5c8b;
    color: #FFF;
    border: 1px solid #74d1e5;
    font-size: 14px;
  }

  .el-pagination.is-background .el-pager li {
    background-color: #021324;
    color: #FFF;
    border: 1px solid #0b5c8b;
    font-size: 14px;
  }

  .el-pagination__jump .el-input__inner {
    font-size: 14px !important;
    color: #fff !important;
    margin: 0 10px !important;
    border: 1px solid #0b5c8b !important;
    background: transparent !important;
    outline: none !important;
    text-align: center !important;
    height: 34px !important;
    width: 50px !important;
    -webkit-box-sizing: border-box !important;
    -moz-box-sizing: border-box !important;
    box-sizing: border-box !important;
  }

  .el-pagination__editor.el-input {
    width: 68px !important;
  }

  .btn-prev {
    width: 78px !important;
    background-color: transparent !important;
    display: inline-block !important;
    line-height: 32px !important;
    font-size: 14px !important;
    color: #fff !important;
    margin: 0 5px !important;
    border: 1px solid #0b5c8b !important;
  }

  .btn-next {
    width: 78px !important;
    background-color: transparent !important;
    display: inline-block !important;
    line-height: 32px !important;
    font-size: 14px !important;
    color: #fff !important;
    margin: 0 5px !important;
    border: 1px solid #0b5c8b !important;
  }

  .page .go {
    width: 60px;
    margin-left: 10px;
    position: relative;
    top: -30px;
    right: -354px;
  }

</style>
